package com.hmall.item.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmall.item.mapper.ItemMapper;
import com.hmall.item.pojo.Item;
import com.hmall.item.service.IItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ItemService extends ServiceImpl<ItemMapper, Item> implements IItemService {
    @Autowired
    private ItemMapper itemMapper;


    @Override
    public Item FindById(Long id) {
        return itemMapper.selectById(id);

    }

    @Override
    public void insert(Item item) {
        itemMapper.insert(item);
    }

    @Override
    public void OnAndOff(Long id, Integer status) {
        Item item=itemMapper.selectById(id);
        item.setStatus(status);
        item.setCreateTime(new Date());
        item.setUpdateTime(new Date());
        itemMapper.updateById(item);
    }

    @Override
    public void DeleteById(Long id) {
        itemMapper.deleteById(id);
    }
}
